package com.market.manage.controller;

import com.market.manage.po.Article;
import com.market.manage.service.ArticleService;
import com.market.po.Result;
import com.market.utils.FileUtil;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@CrossOrigin
@RestController
@RequestMapping(value = "/article")
/*Controller中主要是接受前端传来的http请求，获取请求参数等*/
public class ArticleController {
    @Resource
    private ArticleService articleServiceImpl;

    @GetMapping("/count")
    public Long countUsers() {
        return articleServiceImpl.count();
    }

    @GetMapping("/getArticle")
    public Result getArticle(Long userId, Long pageIndex) {
        return articleServiceImpl.getAllArticle(userId, pageIndex);
    }

    @GetMapping("/getArticleById")
    public Article getArticleById(Long id) {
        return articleServiceImpl.getById(id);
    }

    @GetMapping("/updStatus")
    public void updStatus(Long id, String status) {
        articleServiceImpl.updStatus(id, status);
    }

    @GetMapping("/delete")
    public void delete(Long id) {
        articleServiceImpl.delete(id);
    }
}
